;MEGAMI TENSEI DTE ROUTINE ;For compilation with X816 ;Note that the following three lines are NECESSARY because X816 is a compiler for ;the SUPER NES and NOT the normal NES. The following will basically "fool" x816 into ;compiling NES code instead of SNES code. ;NOTE: Manually insert a JSR $RoutineAddress at $AF24. Do not forget to add $10 to this ;address to compensate for the iNES header! .org $8000 .mem 8 .index 8 DTE_Routine: LDY $0658 ;This was the first command I overwrote with the jump to the routine. LDA ($BE),Y ;This is the second. CMP #$30 ;DTE Range compare 1 BCC End ;If A is < #$30, skip DTE (Branch if carry clear) CLC ;Clear the carry flag - we get here because CMP #$80 ;DTE Range Compare 2 BCS End ;If A is >=#$80, skip DTE (Branch if carry set) ;If we get past the upper and lower bound range compares, we have DTE! RunCheck: STX $07FE ;Store X temporarily to THE DEPTHS OF UNUSED RAM SEC SBC #$30 CLC LDX $07FF ;Load X with a test byte from THE DEPTHS OF UNUSED RAM CPX #$9D ;Compare it with test=true (#$9D in this case) BEQ SecondRun ;If test=true, we're printing the second character BNE FirstRun ;If test=false, we're printing the FIRST character. FirstRun: ;For outputting the first character... LDX #$9D ;Load X with Test=true DEC $0658 ;Decrement load index (which gets transferred into Y) ASL A ;Double A to get DTE Pair Number JMP Base_Routine ;Jump to the shared bits of the routine (4C2780) SecondRun: ASL A ;Double A for DTE Pair Number CLC ;Clear the carry cuz we're gonna add ADC #$01 ;Increment the accumulator ;A is now the index location of the second byte in the DTE Pair. LDX #$00 ;Load X with Test=FALSE Base_Routine: STX $07FF ;Store test byte to THE DEPTHS OF UNUSED RAM TAX ;Transer A to X for the DTE table lookup LDA $DTETable,X ;Load A with where ever your DTE table happens to be,X LDX $07FE ;Restore X from before routine End: JMP $AF29 ;Jump back to the routine Create_DTE_Table: .DSW 80 ;Create an 80 ($50) byte empty DTE table to be later filled in ;This gets put -immediately- after the routine.